package org.ds.blog.controller;

import org.ds.blog.model.Response;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author glx
 */
@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello() {
        return "Hello JWT !";
    }
    @PreAuthorize("hasAuthority('ROLE_NORMAL')")
    @GetMapping("/normal/test")
    public Response test1() {
        return Response.ok().message("ROLE_NORMAL /normal/test接口调用成功！");
    }
    @PreAuthorize("hasAuthority('ROLE_ADMIN')")
    @GetMapping("/admin/test")
    public Response test2() {
        return Response.ok().message("ROLE_ADMIN /admin/test接口调用成功！");
    }
}
